package com.cn.controller.shebaoManager;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cn.entity.TbSocialInsurance;
import com.cn.service.shebao.SheBaoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @Author 社保管理控制层
 * @Date 2021/6/3 18:07
 * @Package com.cn.controller.shebaoManager
 * @Version 1.0
 */


@RequestMapping("/shebaoManager")
@Controller
public class SheBaoManagerController {

    @Autowired
    private SheBaoService shebaoService;
    /*
    分页查询
     */
    @RequestMapping("/shebaoList")
    public String shebaoList(Long id,String idCard,String sbCard,Integer pageNum,Model model){
        Page<TbSocialInsurance> tbSocialInsurancePage = shebaoService.allTbSocialInsurance(id, idCard, sbCard,pageNum);
        model.addAttribute("page",tbSocialInsurancePage);
        return "shebaoList/saved_resource";
    }
    /*
    跳转添加社保人信息页面
     */
    @RequestMapping("/addShebaoHtml")
    public String addShebaoHtml(){
        return "addShebao/saved_resource";
    }
    /*
    添加社保人信息
     */
    @RequestMapping("/addShebao")
    public String addShebao(TbSocialInsurance tbSocialInsurance){
        shebaoService.addShebao(tbSocialInsurance);
        return "redirect:shebaoManager/shebaoList";
    }
    /*
    删除
     */
    @RequestMapping("/delShebao")
    public String delShebao(Long id){
        shebaoService.delShebao(id);
        return "redirect:shebaoManager/shebaoList";
    }
    /*
    根据id查询社保人信息
     */
    @RequestMapping("/queryById")
    public String queryById(Long id,Model model){
        TbSocialInsurance tbSocialInsurance = shebaoService.queryById(id);
        model.addAttribute("shebao",tbSocialInsurance);
        return "updateShebao/saved_resource";
    }

}
